package com.mustafaiev.tair.cts.provider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;

import com.mustafaiev.tair.cts.authentication.CostsTrackingSystemAuthToken;
import com.mustafaiev.tair.cts.service.AuthenticationService;

public class CostsTrackingSystemAuthenticationProvider implements
		AuthenticationProvider {

	@Autowired
	private AuthenticationService authenticationService;

	@Override
	public Authentication authenticate(final Authentication authentication)
			throws AuthenticationException {
		final Authentication auth = this.authenticationService
				.authenticate(authentication);
		return auth;
	}

	@Override
	public boolean supports(final Class<?> authentication) {
		return CostsTrackingSystemAuthToken.class.equals(authentication);
	}

}
